package com.betting.enums;

import lombok.Getter;
import java.math.BigDecimal;

@Getter
public enum BetResult {
    WIN("赢", (betAmount, odds) -> 
        betAmount.multiply(odds)),
    
    HALF_WIN("赢一半", (betAmount, odds) -> 
        betAmount.multiply(odds).multiply(BigDecimal.valueOf(0.5))),
    
    DRAW("和", (betAmount, odds) -> 
        BigDecimal.ZERO),
    
    HALF_LOSE("输一半", (betAmount, odds) -> 
        betAmount.multiply(BigDecimal.valueOf(-0.5))),
    
    LOSE("输", (betAmount, odds) -> 
        betAmount.multiply(BigDecimal.valueOf(-1.0)));

    private final String description;
    private final ResultCalculator calculator;

    BetResult(String description, ResultCalculator calculator) {
        this.description = description;
        this.calculator = calculator;
    }

    public BigDecimal calculateResultAmount(BigDecimal betAmount, BigDecimal odds) {
        return calculator.calculate(betAmount, odds);
    }

    @FunctionalInterface
    private interface ResultCalculator {
        BigDecimal calculate(BigDecimal betAmount, BigDecimal odds);
    }
} 